************************************************************************************************************************
************************************************************************************************************************
******************************************** 1. SURVEY ANALYSIS ********************************************************
***************************************************** USA **************************************************************
************************************************************************************************************************

clear all 
set more off

global path_export1 "${path_results}/Data_Clean"

capture mkdir "${path_export1}"



************************************************************************************************************************

***** 1. SURVEY ROUND 1

************************************************************************************************************************
		
	**** 1.1 I open the round 1 Survey

	clear all
	
	use "${path_bases}\dta/USA_Ageism_Round1_Final.dta"
	
	**** 1.2 Putting order and names
		
		*** 1.2.1 I create a variable to keep the order in tha dataset

		gen double numdate = clock(startdate, "MDY hm")
		format numdate %20.0g
		gsort numdate 
	
		*** 1.2.2 I put names and labels
	
		label variable consent "Consent to the research"
		label variable age_category "Age category"
		label variable education "Highest degree or level of school"
		label variable gender "Gender"
		label variable partisanship "Partisanship"
		label variable dem_strong "Strong Democrat"
		label variable rep_strong "Strong Republican"
		label variable lean_partisan "Party leaning"
		label variable ideology_1 "Ideology scale"
		label variable attention "Attention check"
		label variable dem_statements_1 "Statement1: Democratic systems are not effective at maintaining order and stability"
		label variable dem_statements_2 "Statement2: Democratic governments are indecisive and full of problems"
		label variable dem_statements_3 "Statement3: Under a democratic system, the country's economic performance is weak."
		label variable dem_statements_4 "Statement4: Democracy is better than any other system of government."
		label variable dem_define_1 "Importance for being democracy: Political leaders are elected in competitive elections."
		label variable dem_define_2 "Importance for being democracy: Political leaders implement policies that reflect the preferences of the majority in the country."
		label variable dem_define_3 "Importance for being democracy: Individual political rights are protected, such as freedom of speech and freedom to protest."
		label variable dem_define_4 "Importance for being democracy: Social minorities are protected from discrimination by the majority."
		label variable dem_define_5 "Importance for being democracy: Economic inequality is low."
		label variable dem_define_6 "Importance for being democracy: Political leaders are honest and not corrupt."
		label variable age30_represent "Likely representation by a 30 years old politician"
		label variable age50_represent "Likely representation by a 50 years old politician"
		label variable age70_represent "Likely representation by a 70 years old politician"
		label variable age_gap_problem "Age-gap statement: It is a problem when most political leaders are much older than the citizens of their country"
		label variable old_leaders_effect "Age-gap statement: Older political leaders are more effective than younger political leaders at governing"
		label variable old_leaders_care "Age-gap statement: Older political leaders are less likely than young political leaders to care about what young people think"
		label variable experience_better "Age-gap statement: More experienced political leaders are better political leaders"
		label variable politician_age "Do you think that politicians in your country are generally..."
		label variable age "Age"
		label variable state "State"
		label variable define_young_1 "Age when people stop being young"
		label variable define_old_1 "Age when people start being old"
		label variable age_identity_1 "Age identity: Younger People"
		label variable age_identity_2 "Age identity: Middle-Aged People"
		label variable age_identity_3 "Age identity: Older People"
		label variable age_daily_activity_1 "Interaction with: Under 18"
		label variable age_daily_activity_2 "Interaction with: 18 to 30"
		label variable age_daily_activity_3 "Interaction with: 31 to 40"
		label variable age_daily_activity_4 "Interaction with: 41 to 55"
		label variable age_daily_activity_5 "Interaction with: 56 to 70"
		label variable age_daily_activity_6 "Interaction with: 71 and older"
		label variable age_socialize_1 "Socialization with: Under 18"
		label variable age_socialize_2 "Socialization with: 18 to 30"
		label variable age_socialize_3 "Socialization with: 31 to 40"
		label variable age_socialize_4 "Socialization with: 41 to 55"
		label variable age_socialize_5 "Socialization with: 56 to 70"
		label variable age_socialize_6 "Socialization with: 71 and older"
		label variable age_comfort_1 "Comfort with: Under 18"
		label variable age_comfort_2 "Comfort with: 18 to 30"
		label variable age_comfort_3 "Comfort with: 31 to 40"
		label variable age_comfort_4 "Comfort with: 41 to 55"
		label variable age_comfort_5 "Comfort with: 56 to 70"
		label variable age_comfort_6 "Comfort with: 71 and older"
		label variable age_discriminated_1 "Discrimination statement: I am discriminated against because of my age."
		label variable age_discriminated_2 "Discrimination statement: I face career difficulties because of my age."
		label variable age_discriminated_3 "Discrimination statement: My opinions do not matter much politically because of my age."
		label variable therms_1 "Thermometer: Younger people"
		label variable therms_2 "Thermometer: Middle-aged people"
		label variable therms_3 "Thermometer: Older people"
		label variable therms_4 "Thermometer: Black people"
		label variable therms_5 "Thermometer: Asian people"
		label variable therms_6 "Thermometer: Hispanic people"
		label variable therms_7 "Thermometer: Muslims"
		label variable therms_8 "Thermometer: Christians"
		label variable therms_9 "Thermometer: Jews"
		label variable therms_10 "Thermometer: Immigrants"
		label variable therms_11 "Thermometer: Men"
		label variable therms_12 "Thermometer: Women"
		label variable age_friendly_1 "Friendliness of: Friendliness of: Younger people"
		label variable age_friendly_2 "Friendliness of: Middle-aged people"
		label variable age_friendly_3 "Friendliness of: Older people"
		label variable age_competent_1 "Competense of: Competense of: Younger people"
		label variable age_competent_2 "Competense of: Middle-aged people"
		label variable age_competent_3 "Competense of: Older people"
		label variable age_lazy_1 "Laziness of: Younger people"
		label variable age_lazy_2 "Laziness of: Middle-aged people"
		label variable age_lazy_3 "Laziness of: Older people"
		label variable age_moral_1 "Moral standards of: Younger people"
		label variable age_moral_2 "Moral standards of: Middle-aged people"
		label variable age_moral_3 "Moral standards of: Older people"
		label variable age_respect_1 "Respect for: Younger people"
		label variable age_respect_2 "Respect for: Middle-aged people"
		label variable age_respect_3 "Respect for: Older people"
		label variable age_pity_1 "Pity for: Younger people"
		label variable age_pity_2 "Pity for: Middle-aged people"
		label variable age_pity_3 "Pity for: Older people"
		label variable age_contempt_1 "Contempt for: Younger people"
		label variable age_contempt_2 "Contempt for: Middle-aged people"
		label variable age_contempt_3 "Contempt for: Older people"
		label variable age_politics_1 "Political agreement with: Younger people"
		label variable age_politics_2 "Political agreement with: Middle-aged people"
		label variable age_politics_3 "Political agreement with: Older people"
		label variable age_prejudice "Which statement best describes you?"
		label variable gov_old_health "Age statement: the government spends too much money on healthcare costs for older people"
		label variable gov_young_edu "Age statement: the government spends too much money on educational costs for younger people"
		label variable religion "Religion"
		label variable anxiety_1 "Age anxiety 1: I am anxious about dying"
		label variable anxiety_2 "Age anxiety 2: I am anxious about getting older"
		label variable employment "Employment status"
		label variable ethnicity "Race"
		label variable ethnocentric_1 "Ethnocentric Statement 1: Most other cultures are backwards compared with my culture."
		label variable ethnocentric_2 "Ethnocentric Statement 2: Lifestyles in other cultures are just as valid as those in my culture."
		label variable ethnocentric_3 "Ethnocentric Statement 3: People in my culture could learn a lot from people from other countries."
		label variable ethnocentric_4 "Ethnocentric Statement 4: People from other cultures act strangely when they come to my culture."
		label variable cintid "cintid"
		label variable mobile "Mobile"
		label variable q_datapolicyviolations "Q_DataPolicyViolations"	
	
	**** 1.3 I leave only the correct observations
	
		*** 1.3.1 Checking how many respondents finished survey to the very end
		
		tab finished
		tab progress
		
		*** 1.3.2 I keep only cint tracked respondents

		codebook cintid
		
		keep if cintid!=""

		*** 1.3.3 I drop the duplicated that did not finish
		
		duplicates report cintid
		duplicates tag cintid, g(dup)
		*br if dup!=0
		
		gsort cintid -progress
		duplicates drop cintid, force
		drop dup
		
		sort numdate
		
		*** 1.3.4 Dropping respondents who failed attention check
	
		tabulate attention
		keep if attention=="Silver"
		
		*** 1.3.5 Dropping respondents who didn´t finished
		
		keep if finished=="TRUE"	
		
		*keep if ethnocentric_4!=""

	
	**** 1.4 Generating control variables
	
		*** 1.4.1 Age
		
		tabulate age_category
		generate young = 1 if age_category=="18-24"|age_category=="25-34"
		replace young = 0 if young!=1 & age_category!=""
		tabulate age
		summarize age,detail
		generate under_40 = 1 if age<41&age!=.
		replace under_40 = 0 if age>40&age!=.
		generate under_30 = 1 if age<31&age!=.
		replace under_30 = 0 if age>30&age!=.
		
		label variable young "Young: 18-34 respondent"
		label variable under_40 "Under 40 years old respondent"
		label variable under_30 "Under 30 years old respondent"

		*** 1.4.2 Education

		tabulate education
		generate university = 1 if education=="Bachelor's degree"|education=="Master's degree"|education=="Doctoral degree"
		replace university = 0 if university!=1 & education!=""
		
		label variable university "Bachelor Degree or above"

		*** 1.4.3 Gender
		
		tabulate gender
		generate female = 1 if gender=="Female"
		replace female = 0 if female!=1 & gender!=""
		
		label variable female "Female respondent"

		*** 1.4.4 Ideology
		
		tabulate ideology_1
		
		label variable ideology_1 "Ideology Identification: 1 Left - 10 - Right"
		
		gen strong_left = 1 if ideology_1==1 | ideology_1==2 | ideology_1==3
		replace strong_left = 0 if strong_left==. & ideology_1!=.
		
		label define sstrong_left_label 1 "Strong Left" 0 "Other"
		label values strong_left sstrong_left_label
		label variable strong_left "Strong Left Ideology"
		
		gen strong_right = 1 if ideology_1==8 | ideology_1==9 | ideology_1==10
		replace strong_right = 0 if strong_right==. & ideology_1!=.
		
		label define strong_right_label 1 "Strong Right" 0 "Other"
		label values strong_right strong_right_label
		label variable strong_right "Strong Right Ideology"

		
		*** 1.4.5 Religion
		
		tabulate religion
		generate christian = 1 if religion=="Catholic Christian"|religion=="Protestant Christian"
		replace christian = 0 if christian!=1&religion!=""
		
		label variable christian "Christian: Catholic or Protestant"

		*** 1.4.6 Unemployed
		
		tabulate employment
		generate unemployed = 1 if employment=="Out of work and looking for work"|employment=="Out of work but not currently looking for work"
		replace unemployed = 0 if unemployed!=1&employment!=""
		
		label variable unemployed "Unemployed"

		*** 1.4.7 State
		
		tabulate state
		
		encode state, gen(state_id)
		label variable state_id "State ID"	

	**** 1.5 I import the IAT results analysis with the Shinny app (Done in R)
	
		*** 1.5.1 I merge the IAT results
		
		merge 1:1 responseid using "${path_bases}\dta/IAToutput_US.dta"
		drop if _merge==2 // 31 do not merge. since they didn´t finish the survey. Only 1100 matched
		drop _merge
		
		*** 1.5.2 I drop the IAT variables
		
		drop q1rp1 q2rp2 q3rp3 q4rp4 q5rp5 q6rp6 q7rp7 q8rn1 q9rn2 q10rn3 q11rn4 q12rn5 q13rn6 q14rn7 q15lp1 q16lp2 q17lp3 q18lp4 q19lp5 q20lp6 q21lp7 q22ln1 q23ln2 q24ln3 q25ln4 q26ln5 q27ln6 q28ln7
	
		*** 1.5.3 I put labels
		
		label variable dscore_iat "Score IAT"

	**** 1.6 Working Democracy Variables
	
		*** 1.6.1 Satisfied with Democracy in Country
		
		tabulate dem_satisfy_1
				
		label variable dem_satisfy_1 "Satisfaction with Democracy"
			
		*** 1.6.2 Democracy Important

		tabulate dem_important_1
		label variable dem_important_1 "How important is it to you that your country is governed by a democracy?"
		
		*** 1.6.3 Democracies Ineffective at Maintaining Order

		tabulate dem_statements_1
		generate dem_order = 5 if dem_statements_1=="Strongly disagree"
		replace dem_order = 4 if dem_statements_1=="Somewhat disagree"
		replace dem_order = 3 if dem_statements_1=="Neither agree nor disagree"
		replace dem_order = 2 if dem_statements_1=="Somewhat agree"
		replace dem_order = 1 if dem_statements_1=="Strongly agree"
		
		label define dem_statements_label 5 "Strongly disagree" 4 "Somewhat disagree" 3 "Neither agree nor disagree" 2 "Somewhat agree" 1 "Strongly agree"
	label values dem_order dem_statements_label
		label variable dem_order "Democratic systems are not effective at maintaining order and stability"
		
		*** 1.6.4 Democracies Indecisive
		
		tabulate dem_statements_2

		generate dem_decisive = 5 if dem_statements_2=="Strongly disagree"
		replace dem_decisive = 4 if dem_statements_2=="Somewhat disagree"
		replace dem_decisive = 3 if dem_statements_2=="Neither agree nor disagree"
		replace dem_decisive = 2 if dem_statements_2=="Somewhat agree"
		replace dem_decisive = 1 if dem_statements_2=="Strongly agree"
		
		label values dem_decisive dem_statements_label
		label variable dem_decisive "Democratic governments are indecisive and full of problems"

		*** 1.6.5 Democracies Perform Poorly on Economics
		
		tabulate dem_statements_3
		
		generate dem_econ = 5 if dem_statements_3=="Strongly disagree"
		replace dem_econ = 4 if dem_statements_3=="Somewhat disagree"
		replace dem_econ = 3 if dem_statements_3=="Neither agree nor disagree"
		replace dem_econ = 2 if dem_statements_3=="Somewhat agree"
		replace dem_econ = 1 if dem_statements_3=="Strongly agree"
		
		label values dem_econ dem_statements_label
		label variable dem_econ "Under a democratic system, the country's economic performance is weak"

		*** 1.6.6 Democracy Better than Any Other System
		
		tabulate dem_statements_4

		generate dem_best = 5 if dem_statements_4=="Strongly agree"
		replace dem_best = 4 if dem_statements_4=="Somewhat agree"
		replace dem_best = 3 if dem_statements_4=="Neither agree nor disagree"
		replace dem_best = 2 if dem_statements_4=="Somewhat disagree"
		replace dem_best = 1 if dem_statements_4=="Strongly disagree"
		
		label define dem_challenge_label 1 "Strongly disagree" 2 "Somewhat disagree" 3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"

		label values dem_best dem_challenge_label
		label variable dem_best "Democracy is better than any other system of government."	
		
		*** 1.6.7 Democracy Index
		
			** 1.6.7.1 I review the variables I plan to group
		
			tab dem_econ
			tab dem_econ, nol
			tab dem_decisive
			tab dem_decisive, nol
			tab dem_order
			tab dem_order, nol
			tab dem_best
			tab dem_best, nol   
			
			** 1.6.7.2 I build the index
		
			egen dem_index=rowmean(dem_econ dem_decisive dem_order dem_best)
			
			tab dem_index
			summ dem_index,d
			
			label variable dem_index "Democracy Index"	
					
		
	**** 1.7 Generating Independent Variables
	
		*** 1.7.1 Politicians are too old
		
		tabulate politician_age

		generate politician_too_old = 1 if politician_age=="Too old"
		replace politician_too_old = 0 if politician_too_old==. & politician_age!=""
		
		label define politician_too_old_label 1 "Too old" 0 "Other"

		label values politician_too_old politician_too_old_label
		label variable politician_too_old "Politicians are too old"	
		
		*** 1.7.2 Politicians right age
		
		tabulate politician_age

		generate politician_right_age = 1 if politician_age=="About the right age"
		replace politician_right_age = 0 if politician_right_age==. & politician_age!=""
		
		label define politician_right_age_label 1 "About the right age" 0 "Other"

		label values politician_right_age politician_right_age_label
		label variable politician_right_age "Politicians are about the right age"	
		
		*** 1.7.3 Politicians too young
		
		tabulate politician_age

		generate politician_too_young = 1 if politician_age=="Too young"
		replace politician_too_young = 0 if politician_too_young==. & politician_age!=""
		
		label define politician_too_young_label 1 "Too young" 0 "Other"

		label values politician_too_young politician_too_young_label
		label variable politician_too_young "Politicians are too young"	
		
		*** 1.7.4 Old leaders care
		
		tabulate old_leaders_care

		generate old_leaders_not_care = 5 if old_leaders_care=="Strongly agree"
		replace old_leaders_not_care = 4 if old_leaders_care=="Somewhat agree"
		replace old_leaders_not_care = 3 if old_leaders_care=="Neither agree nor disagree"
		replace old_leaders_not_care = 2 if old_leaders_care=="Somewhat disagree"
		replace old_leaders_not_care = 1 if old_leaders_care=="Strongly disagree"

		label values old_leaders_not_care dem_challenge_label
		label variable old_leaders_not_care "Older political leaders are less likely than young political leaders to care about what young people think"	
		
		gen dummy_old_not_care=.
		replace dummy_old_not_care=1 if old_leaders_not_care==4 | old_leaders_not_care==5
		replace dummy_old_not_care=0 if dummy_old_not_care==. & old_leaders_not_care!=.
		
		label define dummy_old_not_care_label 1 "Agree" 0 "Neither A/D and Disagree"

		label values dummy_old_not_care dummy_old_not_care_label
		label variable dummy_old_not_care "Older politicians do not care about what young people think"

		*** 1.7.5 Age gap problem
		
		tabulate age_gap_problem
		rename age_gap_problem age_gap_problem_old

		generate age_gap_problem = 5 if age_gap_problem_old=="Strongly agree"
		replace age_gap_problem = 4 if age_gap_problem_old=="Somewhat agree"
		replace age_gap_problem = 3 if age_gap_problem_old=="Neither agree nor disagree"
		replace age_gap_problem = 2 if age_gap_problem_old=="Somewhat disagree"
		replace age_gap_problem = 1 if age_gap_problem_old=="Strongly disagree"

		label values age_gap_problem dem_challenge_label
		label variable age_gap_problem "It is a problem when most political leaders are much older than the citizens of their country"	
		
		gen dummy_age_gap_problem=.
		replace dummy_age_gap_problem=1 if age_gap_problem==4 | age_gap_problem==5
		replace dummy_age_gap_problem=0 if dummy_age_gap_problem==. & age_gap_problem!=.
		
		label values dummy_age_gap_problem dummy_old_not_care_label
		label variable dummy_age_gap_problem "Age gap is a problem"
		
		*** 1.7.6 Age discrimination: My opinions do not matter much politically because of my age
		
		tabulate age_discriminated_3

		generate opinion_discr_age = 5 if age_discriminated_3=="Strongly agree"
		replace opinion_discr_age = 4 if age_discriminated_3=="Somewhat agree"
		replace opinion_discr_age = 3 if age_discriminated_3=="Neither agree nor disagree"
		replace opinion_discr_age = 2 if age_discriminated_3=="Somewhat disagree"
		replace opinion_discr_age = 1 if age_discriminated_3=="Strongly disagree"

		label values opinion_discr_age dem_challenge_label
		label variable opinion_discr_age "My opinions do not matter much politically because of my age"	
		
		gen dummy_opinion_discr_age=.
		replace dummy_opinion_discr_age=1 if opinion_discr_age==4 | opinion_discr_age==5
		replace dummy_opinion_discr_age=0 if dummy_opinion_discr_age==. & opinion_discr_age!=.
		
		label values dummy_opinion_discr_age dummy_old_not_care_label
		label variable dummy_opinion_discr_age "My opinions do not matter because of my age"
		
		
		*** 1.7.7 Political Agreement with groups
		
			** 1.7.7.1 Young
		
			tabulate age_politics_1
			
			generate pol_agreement_young = 1 if age_politics_1=="Strongly agree"
			replace pol_agreement_young = 2 if age_politics_1=="Somewhat agree"
			replace pol_agreement_young = 3 if age_politics_1=="Somewhat disagree"
			replace pol_agreement_young = 4 if age_politics_1=="Strongly disagree"
			
			label define agreement_label 4 "Strongly disagree" 3 "Somewhat disagree" 2 "Somewhat agree" 1 "Strongly agree"
			
			label values pol_agreement_young agreement_label
			label variable pol_agreement_young "How much do you agree or disagree with the political views of young people?"	

			generate pol_disagreement_young = 1 if pol_agreement_young==3 | pol_agreement_young==4
			replace pol_disagreement_young = 0 if pol_disagreement_young==. & pol_agreement_young!=.
			
			label define disagreement_label 1 "Disagreement" 0 "Agreement"

			label values pol_disagreement_young disagreement_label
			label variable pol_disagreement_young "Political agreement or disagreement with young people"	
			
			** 1.7.7.2 Middle-Aged
		
			tabulate age_politics_2
			
			generate pol_agreement_middle = 1 if age_politics_2=="Strongly agree"
			replace pol_agreement_middle = 2 if age_politics_2=="Somewhat agree"
			replace pol_agreement_middle = 3 if age_politics_2=="Somewhat disagree"
			replace pol_agreement_middle = 4 if age_politics_2=="Strongly disagree"
			
			label values pol_agreement_middle agreement_label
			label variable pol_agreement_middle "How much do you agree or disagree with the political views of middle-aged people?"	

			generate pol_disagreement_middle = 1 if pol_agreement_middle==3 | pol_agreement_middle==4
			replace pol_disagreement_middle = 0 if pol_disagreement_middle==. & pol_agreement_middle!=.
			
			label values pol_disagreement_middle disagreement_label
			label variable pol_disagreement_middle "Political agreement or disagreement with middle-aged people"	
			
			** 1.7.7.3 Old
		
			tabulate age_politics_3
			
			generate pol_agreement_old = 1 if age_politics_3=="Strongly agree"
			replace pol_agreement_old = 2 if age_politics_3=="Somewhat agree"
			replace pol_agreement_old = 3 if age_politics_3=="Somewhat disagree"
			replace pol_agreement_old = 4 if age_politics_3=="Strongly disagree"
			
			label values pol_agreement_old agreement_label
			label variable pol_agreement_old "How much do you agree or disagree with the political views of old people?"	

			generate pol_disagreement_old = 1 if pol_agreement_old==3 | pol_agreement_old==4
			replace pol_disagreement_old = 0 if pol_disagreement_old==. & pol_agreement_old!=.
			
			label values pol_disagreement_old disagreement_label
			label variable pol_disagreement_old "Political agreement or disagreement with old people"	
			
		
	**** 1.8 Ageism Variables
	
		*** 1.8.1 Friendliness of: Older people
		
		tabulate age_friendly_3

		generate old_friendly = 1 if age_friendly_3=="Very friendly"
		replace old_friendly = 2 if age_friendly_3=="Somewhat friendly"
		replace old_friendly = 3 if age_friendly_3=="Not very friendly"
		replace old_friendly = 4 if age_friendly_3=="Not friendly at all"
		
		label define friendly_label 1 "Very friendly" 2 "Somewhat friendly" 3 "Not very friendly" 4 "Not friendly at all"

		label values old_friendly friendly_label
		label variable old_friendly "Friendliness of: Older people"	
		
		*** 1.8.2 Competense of: Older people
		
		tabulate age_competent_3

		generate old_competent = 1 if age_competent_3=="Very competent"
		replace old_competent = 2 if age_competent_3=="Somewhat competent"
		replace old_competent = 3 if age_competent_3=="Not very competent"
		replace old_competent = 4 if age_competent_3=="Not competent at all"
		
		label define competent_label 1 "Very competent" 2 "Somewhat competent" 3 "Not very competent" 4 "Not competent at all"

		label values old_competent competent_label
		label variable old_competent "Competense of: Older people"	
		
		*** 1.8.3 Laziness of: Older people
		
		tabulate age_lazy_3

		generate old_lazy = 1 if age_lazy_3=="Not lazy at all"
		replace old_lazy = 2 if age_lazy_3=="Not very lazy"
		replace old_lazy = 3 if age_lazy_3=="Somewhat lazy"
		replace old_lazy = 4 if age_lazy_3=="Very lazy"
		
		label define lazy_label 1 "Not lazy at all" 2 "Not very lazy" 3 "Somewhat lazy" 4 "Very lazy"

		label values old_lazy lazy_label
		label variable old_lazy "Laziness of: Older people"	
		
		*** 1.8.4 Moral standards of: Older people
		
		tabulate age_moral_3

		generate old_moral = 1 if age_moral_3=="Strongly agree"
		replace old_moral = 2 if age_moral_3=="Somewhat agree"
		replace old_moral = 3 if age_moral_3=="Somewhat disagree"
		replace old_moral = 4 if age_moral_3=="Strongly disagree"
		
		label define moral_label 1 "High Moral Standards" 2 "Some High Moral Standards" 3 "Some few Moral Standards" 4 "No Moral Standards"

		label values old_moral moral_label
		label variable old_moral "Moral standards of: Older people"	
		
		*** 1.8.5 Respect for: Older people
		
		tabulate age_respect_3

		generate old_respect = 1 if age_respect_3=="A lot of respect"
		replace old_respect = 2 if age_respect_3=="Some respect"
		replace old_respect = 3 if age_respect_3=="Not very much respect"
		replace old_respect = 4 if age_respect_3=="No respect at all"
		
		label define respect_label 1 "A lot of respect" 2 "Some respect" 3 "Not very much respect" 4 "No respect at all"

		label values old_respect respect_label
		label variable old_respect "Respect for: Older people"	
		
		*** 1.8.6 Pity for: Older people
		
		tabulate age_pity_3

		generate old_pity = 1 if age_pity_3=="No pity at all"
		replace old_pity = 2 if age_pity_3=="Not very much pity"
		replace old_pity = 3 if age_pity_3=="Some pity"
		replace old_pity = 4 if age_pity_3=="A lot of pity"
		
		label define pity_label 1 "No pity at all" 2 "Not very much pity" 3 "Some pity" 4 "A lot of pity"

		label values old_pity pity_label
		label variable old_pity "Pity for: Older people"
		
		*** 1.8.7 Contempt for: Older people
		
		tabulate age_contempt_3

		generate old_contempt = 1 if age_contempt_3=="No contempt at all"
		replace old_contempt = 2 if age_contempt_3=="Not very much contempt"
		replace old_contempt = 3 if age_contempt_3=="Some contempt"
		replace old_contempt = 4 if age_contempt_3=="A lot of contempt"
		
		label define contempt_label 1 "No contempt at all" 2 "Not very much contempt" 3 "Some contempt" 4 "A lot of contempt"

		label values old_contempt contempt_label
		label variable old_contempt "Contempt for: Older people"
		
		*** 1.8.8 I build Ageism INDEX
		
			** 1.8.8.1 I review the variables I plan to group
		
			tab old_friendly
			tab old_friendly, nol
			tab old_competent
			tab old_competent, nol
			tab old_lazy
			tab old_lazy, nol
			tab old_moral
			tab old_moral, nol 
			tab old_respect
			tab old_respect, nol
			tab old_pity
			tab old_pity, nol
			tab old_contempt
			tab old_contempt, nol			      
			
			** 1.8.8.2 I build the index
		
			egen ageism_index=rowmean(old_friendly old_competent old_lazy old_moral old_respect old_pity old_contempt)
			
			tab ageism_index
			summ ageism_index,d
			
			label variable ageism_index "Ageism Index"	
			
		*** 1.8.9 I build Ageism based on Thermometer
		
			** 1.8.9.1 Absolute measure
			
			tabulate therms_1
			tabulate therms_2
			tabulate therms_3

			gen therms_young = therms_1
			label variable therms_young "Absolute Thermometer: Younger people"
			
			gen therms_middle_age = therms_2
			label variable therms_middle_age "Absolute Thermometer: Middle-aged people"
			
			gen ageism_abs_therms_old = therms_3
			label variable ageism_abs_therms_old "Absolute Thermometer: Older people"

			** 1.8.9.2 Relative measure
			
			egen therms_other=rowmean(therms_young therms_middle_age)
			
			gen ageism_rel_therms_old= therms_other - ageism_abs_therms_old  
			
			drop therms_other

			label variable ageism_rel_therms_old "Relative Thermometer: Older people"
			
			summ ageism_rel_therms_old
			summ ageism_rel_therms_old, d

		*** 1.8.10 I build Ageism based on Declared age prejudice
		
		tab age_prejudice
		
		gen ageism_explicit=.
		
		replace ageism_explicit = 1 if age_prejudice=="I strongly prefer old people to young people"
		replace ageism_explicit = 2 if age_prejudice=="I moderately prefer old people to young people"
		replace ageism_explicit = 3 if age_prejudice=="I slightly prefer old people to young people"
		replace ageism_explicit = 4 if age_prejudice=="I like young people and old people equally"
		replace ageism_explicit = 5 if age_prejudice=="I slightly prefer young people to old people"
		replace ageism_explicit = 6 if age_prejudice=="I moderately prefer young people to old people"
		replace ageism_explicit = 7 if age_prejudice=="I strongly prefer young people to old people"

		label define prejudice_label 1 "I strongly prefer old people to young people" 2 "I moderately prefer old people to young people" 3 "I slightly prefer old people to young people" 4 "I like young people and old people equally" 5 "I slightly prefer young people to old people" 6 "I moderately prefer young people to old people" 7 "I strongly prefer young people to old people"

		label values ageism_explicit prejudice_label
		label variable ageism_explicit "Explicit Ageism"
		
	**** 1.9 Anxiety to get old variables 
	
		*** 1.9.1 Anxeity for dying
		
		tabulate anxiety_1

		generate anxiety_die = 5 if anxiety_1=="Strongly agree"
		replace anxiety_die = 4 if anxiety_1=="Somewhat agree"
		replace anxiety_die = 3 if anxiety_1=="Neither agree nor disagree"
		replace anxiety_die = 2 if anxiety_1=="Somewhat disagree"
		replace anxiety_die = 1 if anxiety_1=="Strongly disagree"
		
		label define anxiety_die_label 1 "Strongly disagree" 2 "Somewhat disagree" 3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"

		label values anxiety_die anxiety_die_label
		label variable anxiety_die "Anxiety About Dying"	
		
		*** 1.9.2 Anxeity for getting older
		
		tabulate anxiety_2

		generate anxiety_old = 5 if anxiety_2=="Strongly agree"
		replace anxiety_old = 4 if anxiety_2=="Somewhat agree"
		replace anxiety_old = 3 if anxiety_2=="Neither agree nor disagree"
		replace anxiety_old = 2 if anxiety_2=="Somewhat disagree"
		replace anxiety_old = 1 if anxiety_2=="Strongly disagree"
		
		label define anxiety_old_label 1 "Strongly disagree" 2 "Somewhat disagree" 3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"

		label values anxiety_old anxiety_old_label
		label variable anxiety_old "Anxiety About Dying"
		
		*** 1.9.3 I build Anxiety INDEX
		
			** 1.9.3.1 I review the variables I plan to group
		
			tab anxiety_die
			tab anxiety_die, nol
			tab anxiety_old
			tab anxiety_old, nol
			
			** 1.9.3.2 I build the index
		
			egen anxiety_index=rowmean(anxiety_die anxiety_old)
			
			tab anxiety_index
			summ anxiety_index,d
			
			label variable anxiety_index "Anxiety Index"	
		
		
	**** 1.10 Intergenerational conflict
	
		*** 1.10.1 I build INDEX for intergenerational conflict
		
			** 1.10.1.1 I work the variable politicians age

			tabulate politician_age
			rename politician_age politician_age_old

			generate politician_age = 1 if politician_age_old=="Too young"
			replace politician_age = 2 if politician_age_old=="About the right age"
			replace politician_age = 3 if politician_age_old=="Too old"
			
			label define politician_age_label 1 "Too young" 2 "About the right age" 3 "Too old"
			
			label values politician_age politician_age_label
			label variable politician_age "Politicians are too old"
		
			** 1.10.1.2 I review the variables I plan to group
		
			tab age_gap_problem
			tab age_gap_problem, nol
			tab politician_age
			tab politician_age, nol
			tab old_leaders_not_care
			tab old_leaders_not_care, nol
			
			** 1.10.1.3 I standardize the variables
			
			foreach x in age_gap_problem politician_age old_leaders_not_care {
			
			summ `x', d
			gen s_`x'=(`x'-r(mean))/r(sd) 
				
			}

			
			** 1.10.1.4 I build the index
		
			egen old_leaders_bad_index=rowmean(s_age_gap_problem s_politician_age s_old_leaders_not_care)
			
			tab old_leaders_bad_index
			summ old_leaders_bad_index,d
			
			label variable old_leaders_bad_index "Generational Grievances Index"
			
		*** 1.10.2 I build PCA for intergenerational conflict
		
			** 1.10.2.1  I build PCA
			
			pca s_age_gap_problem s_politician_age s_old_leaders_not_care
			predict pca_old_leaders_bad, score
			summarize pca_old_leaders_bad
			alpha s_age_gap_problem s_politician_age s_old_leaders_not_care, std

		*** 1.10.3 I build INDEX for Personal Grievences
		
			** 1.10.3.1 I review the variables I plan to group
		
			tab pol_agreement_old
			tab pol_agreement_old, nol
			tab opinion_discr_age
			tab opinion_discr_age, nol
			
			
			** 1.10.3.2 I standardize the variables
			
			foreach x in pol_agreement_old opinion_discr_age {
			
			summ `x', d
			gen s_`x'=(`x'-r(mean))/r(sd) 
				
			}

			
			** 1.10.1.4 I build the index
		
			egen personal_grievances_index=rowmean(s_pol_agreement_old s_opinion_discr_age)
			
			tab personal_grievances_index
			summ personal_grievances_index,d
			
			label variable personal_grievances_index "Personal Grievances Index"
			
			
	**** 1.11 Contact to old people index 
	
		*** 1.11.1 Interaction with old people
		
		tabulate age_daily_activity_6

		generate interact_old = 4 if age_daily_activity_6=="Very often"
		replace interact_old = 3 if age_daily_activity_6=="Somewhat often"
		replace interact_old = 2 if age_daily_activity_6=="Not very often"
		replace interact_old = 1 if age_daily_activity_6=="Not at all"
		
		label define interact_old_label 1 "Not at all" 2 "Not very often" 3 "Somewhat often" 4 "Very often"

		label values interact_old interact_old_label
		label variable interact_old "Interact Old People"	
		
		*** 1.11.2 Socialization with old people
		
		tabulate age_socialize_6

		generate socialization_old = 4 if age_socialize_6=="Very often"
		replace socialization_old = 3 if age_socialize_6=="Somewhat often"
		replace socialization_old = 2 if age_socialize_6=="Not very often"
		replace socialization_old = 1 if age_socialize_6=="Not at all"
		
		label values socialization_old interact_old_label
		label variable socialization_old "Socialization Old People"
		
		*** 1.11.3 Comfort with old people
		
		tabulate age_comfort_6

		generate comfort_old = 4 if age_comfort_6=="Very comfortable"
		replace comfort_old = 3 if age_comfort_6=="Somewhat comfortable"
		replace comfort_old = 2 if age_comfort_6=="Somewhat uncomfortable"
		replace comfort_old = 1 if age_comfort_6=="Very uncomfortable"
		
		label define comfort_old_label 1 "Very uncomfortable" 2 "Somewhat uncomfortable" 3 "Somewhat comfortable" 4 "Very comfortable"
		
		label values comfort_old comfort_old_label
		label variable comfort_old "Comfort Old People"
		
		*** 1.11.4 I build Anxiety INDEX
		
			** 1.11.4.1 I review the variables I plan to group
		
			tab interact_old
			tab interact_old, nol
			tab socialization_old
			tab socialization_old, nol
			tab comfort_old
			tab comfort_old, nol
			
			
			** 1.11.4.2 I build the index
		
			egen contact_index=rowmean(interact_old socialization_old comfort_old)
			
			tab contact_index
			summ contact_index,d
			
			label variable contact_index "Contact With Old People Index"	
			
	**** 1.12 Ethnocentric index 
	
		*** 1.12.1 Ethnocentric question 1
		
		tabulate ethnocentric_1
		
		rename ethnocentric_1 ethnocentric_1_old 
		
		generate ethnocentric_1 = 5 if ethnocentric_1_old=="Strongly agree"
		replace ethnocentric_1 = 4 if ethnocentric_1_old=="Somewhat agree"
		replace ethnocentric_1 = 3 if ethnocentric_1_old=="Neither agree nor disagree"
		replace ethnocentric_1 = 2 if ethnocentric_1_old=="Somewhat disagree"
		replace ethnocentric_1 = 1 if ethnocentric_1_old=="Strongly disagree"
		
		label define ethno_old_label 1 "Strongly disagree" 2 "Somewhat disagree" 3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"
		
		label values ethnocentric_1 ethno_old_label
		label variable ethnocentric_1 "Ethnocentric Statement 1: Most other cultures are backwards compared with my culture."
		
		*** 1.12.2 Ethnocentric question 2
		
		tabulate ethnocentric_2
		
		rename ethnocentric_2 ethnocentric_2_old 
		
		generate ethnocentric_2 = 1 if ethnocentric_2_old=="Strongly agree"
		replace ethnocentric_2 = 2 if ethnocentric_2_old=="Somewhat agree"
		replace ethnocentric_2 = 3 if ethnocentric_2_old=="Neither agree nor disagree"
		replace ethnocentric_2 = 4 if ethnocentric_2_old=="Somewhat disagree"
		replace ethnocentric_2 = 5 if ethnocentric_2_old=="Strongly disagree"
		
		label define ethno_old_label2 5 "Strongly disagree" 4 "Somewhat disagree" 3 "Neither agree nor disagree" 2 "Somewhat agree" 1 "Strongly agree"
				
		label values ethnocentric_2 ethno_old_label2
		label variable ethnocentric_2 "Ethnocentric Statement 2: Lifestyles in other cultures are just as valid as those in my culture."
		
		*** 1.12.3 Ethnocentric question 3
		
		tabulate ethnocentric_3
		
		rename ethnocentric_3 ethnocentric_3_old 
		
		generate ethnocentric_3 = 1 if ethnocentric_3_old=="Strongly agree"
		replace ethnocentric_3 = 2 if ethnocentric_3_old=="Somewhat agree"
		replace ethnocentric_3 = 3 if ethnocentric_3_old=="Neither agree nor disagree"
		replace ethnocentric_3 = 4 if ethnocentric_3_old=="Somewhat disagree"
		replace ethnocentric_3 = 5 if ethnocentric_3_old=="Strongly disagree"

		label values ethnocentric_3 ethno_old_label2
		label variable ethnocentric_3 "Ethnocentric Statement 3: People in my culture could learn a lot from people from other countries."
		
		*** 1.12.4 Ethnocentric question 4
		
		tabulate ethnocentric_4
		
		rename ethnocentric_4 ethnocentric_4_old 
		
		generate ethnocentric_4 = 5 if ethnocentric_4_old=="Strongly agree"
		replace ethnocentric_4 = 4 if ethnocentric_4_old=="Somewhat agree"
		replace ethnocentric_4 = 3 if ethnocentric_4_old=="Neither agree nor disagree"
		replace ethnocentric_4 = 2 if ethnocentric_4_old=="Somewhat disagree"
		replace ethnocentric_4 = 1 if ethnocentric_4_old=="Strongly disagree"
		
		label values ethnocentric_4 ethno_old_label
		label variable ethnocentric_4 "Ethnocentric Statement 4: People from other cultures act strangely when they come to my culture."
		
		*** 1.12.5 I build Ethnocentrism INDEX
		
			** 1.12.5.1 I review the variables I plan to group
		
			tab ethnocentric_1
			tab ethnocentric_1, nol
			tab ethnocentric_2
			tab ethnocentric_2, nol
			tab ethnocentric_3
			tab ethnocentric_3, nol
			tab ethnocentric_4
			tab ethnocentric_4, nol
			
			
			** 1.12.5.2 I build the index
		
			egen ethnocentric_index=rowmean(ethnocentric_1 ethnocentric_2 ethnocentric_3 ethnocentric_4)
			
			tab ethnocentric_index
			summ ethnocentric_index,d
			
			label variable ethnocentric_index "Ethnocentric Index"
			
		
	**** 1.13 I leave the variables I care 
	
	keep startdate enddate cintid progress durationinseconds finished recordeddate responseid distributionchannel userlanguage consent numdate age_category education gender partisanship dem_strong rep_strong lean_partisan ideology_1 attention age state religion employment ethnicity ethnocentric_1 ethnocentric_2 ethnocentric_3 ethnocentric_4 young under_40 under_30 university female christian unemployed state_id dscore_iat  politician_too_old politician_right_age politician_too_young old_leaders_not_care dummy_old_not_care  strong_left strong_right dem_important_1 dem_satisfy_1 dem_order dem_decisive dem_econ dem_best dem_index age_gap_problem dummy_age_gap_problem opinion_discr_age dummy_opinion_discr_age pol_agreement_young pol_disagreement_young pol_agreement_middle pol_disagreement_middle pol_agreement_old pol_disagreement_old	dem_define_1 dem_define_2 dem_define_3 dem_define_4 dem_define_5 dem_define_6 age30_represent age50_represent age70_represent old_leaders_effect old_leaders_care experience_better politician_age define_young_1 define_old_1 age_identity_1 age_identity_2 age_identity_3 age_daily_activity_1 age_daily_activity_2 age_daily_activity_3 age_daily_activity_4 age_daily_activity_5 age_daily_activity_6 age_socialize_1 age_socialize_2 age_socialize_3 age_socialize_4 age_socialize_5 age_socialize_6 age_comfort_1 age_comfort_2 age_comfort_3 age_comfort_4 age_comfort_5 age_comfort_6 therms_1 therms_2 therms_3 therms_4 therms_5 therms_6 therms_7 therms_8 therms_9 therms_10 therms_11 therms_12 age_friendly_1 age_friendly_2 age_friendly_3 age_competent_1 age_competent_2 age_competent_3 age_lazy_1 age_lazy_2 age_lazy_3 age_moral_1 age_moral_2 age_moral_3 age_respect_1 age_respect_2 age_respect_3 age_pity_1 age_pity_2 age_pity_3 age_contempt_1 age_contempt_2 age_contempt_3 age_prejudice gov_old_health gov_young_edu anxiety_1 anxiety_2 old_friendly old_competent old_lazy old_moral old_respect old_pity old_contempt ageism_index therms_young therms_middle_age ageism_abs_therms_old ageism_rel_therms_old ageism_explicit anxiety_die anxiety_old anxiety_index old_leaders_bad_index pca_old_leaders_bad personal_grievances_index interact_old socialization_old comfort_old contact_index ethnocentric_index
	
	order startdate enddate cintid progress durationinseconds finished recordeddate responseid distributionchannel userlanguage consent numdate age_category education gender partisanship dem_strong rep_strong lean_partisan ideology_1 attention age state religion employment ethnicity ethnocentric_1 ethnocentric_2 ethnocentric_3 ethnocentric_4 young under_40 under_30 university female christian unemployed state_id dscore_iat  politician_too_old politician_right_age politician_too_young old_leaders_not_care dummy_old_not_care  strong_left strong_right dem_important_1 dem_satisfy_1 dem_order dem_decisive dem_econ dem_best dem_index age_gap_problem dummy_age_gap_problem opinion_discr_age dummy_opinion_discr_age pol_agreement_young pol_disagreement_young pol_agreement_middle pol_disagreement_middle pol_agreement_old pol_disagreement_old old_friendly old_competent old_lazy old_moral old_respect old_pity old_contempt ageism_index therms_young therms_middle_age ageism_abs_therms_old ageism_rel_therms_old ageism_explicit anxiety_die anxiety_old anxiety_index old_leaders_bad_index pca_old_leaders_bad personal_grievances_index interact_old socialization_old comfort_old contact_index dem_define_1 dem_define_2 dem_define_3 dem_define_4 dem_define_5 dem_define_6 age30_represent age50_represent age70_represent old_leaders_effect old_leaders_care experience_better politician_age ethnocentric_index define_young_1 define_old_1 age_identity_1 age_identity_2 age_identity_3 age_daily_activity_1 age_daily_activity_2 age_daily_activity_3 age_daily_activity_4 age_daily_activity_5 age_daily_activity_6 age_socialize_1 age_socialize_2 age_socialize_3 age_socialize_4 age_socialize_5 age_socialize_6 age_comfort_1 age_comfort_2 age_comfort_3 age_comfort_4 age_comfort_5 age_comfort_6 therms_1 therms_2 therms_3 therms_4 therms_5 therms_6 therms_7 therms_8 therms_9 therms_10 therms_11 therms_12 age_friendly_1 age_friendly_2 age_friendly_3 age_competent_1 age_competent_2 age_competent_3 age_lazy_1 age_lazy_2 age_lazy_3 age_moral_1 age_moral_2 age_moral_3 age_respect_1 age_respect_2 age_respect_3 age_pity_1 age_pity_2 age_pity_3 age_contempt_1 age_contempt_2 age_contempt_3 age_prejudice gov_old_health gov_young_edu anxiety_1 anxiety_2
	
	**** 1.14 I create the country variable

	generate country = "USA"
	label variable country "Surveyed country"	

	**** 1.15 I save
	
	keep startdate enddate cintid progress durationinseconds finished recordeddate responseid distributionchannel userlanguage numdate ideology_1 age state young under_40 under_30 university female christian unemployed state_id dscore_iat  politician_too_old politician_right_age politician_too_young old_leaders_not_care dummy_old_not_care  strong_left strong_right dem_important_1 dem_satisfy_1 dem_order dem_decisive dem_econ dem_best dem_index age_gap_problem dummy_age_gap_problem opinion_discr_age dummy_opinion_discr_age pol_agreement_young pol_disagreement_young pol_agreement_middle pol_disagreement_middle pol_agreement_old pol_disagreement_old dem_define_1 dem_define_2 dem_define_3 dem_define_4 dem_define_5 dem_define_6 define_young_1 define_old_1 age_identity_1 age_identity_2 age_identity_3  therms_1 therms_2 therms_3 therms_4 therms_5 therms_6 therms_7 therms_8 therms_9 therms_10 therms_11 therms_12 old_friendly old_competent old_lazy old_moral old_respect old_pity old_contempt ageism_index therms_young therms_middle_age ageism_abs_therms_old ageism_rel_therms_old ageism_explicit country anxiety_die anxiety_old anxiety_index old_leaders_bad_index pca_old_leaders_bad personal_grievances_index interact_old socialization_old comfort_old contact_index ethnocentric_index
	
	save "${path_export1}\USA_condensed_Round1",replace

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

		